﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyMainSite.Models;

namespace MyMainSite.Repositories
{
    public static class BlogUserRepository
    {
        #region Public Methods

        public static bool ValidateUser(string username, string password)
        {
            RichardsSiteEntities context = new RichardsSiteEntities();

            username = username.ToLower();

            var user = from u in context.BlogUsers
                       where u.UserName.ToLower() == username &&
                             u.Password == password
                       select u;

            return user.FirstOrDefault() != null;
        }

        public static BlogUser GetByUserName(string username)
        {
            RichardsSiteEntities context = new RichardsSiteEntities();

            username = username.ToLower();

            var user = from u in context.BlogUsers
                       where u.UserName.ToLower() == username
                       select u;

            return user.FirstOrDefault();
        }

        #endregion
    }
}